import java.sql.*;
import java.io.*;
import java.util.*;

public class CustomerInterface 
{
	public static Connection connection; //used to hold the jdbc connection to the DB
    public static Statement statement; //used to create an instance of the connection
    public static ResultSet resultSet; //used to hold the result of your query (if one
    // exists)
    private static String query;  //this will hold the query we are using
    public static String username = "cmb155", password = "3626950";
	
	public CustomerInterface()
	{
		System.out.println("instantiated\n");
		/* Making a connection to a DB causes certian exceptions.  In order to handle
		   these, you either put the DB stuff in a try block or have your function
		   throw the Execptions and handle them later.  For this demo I will use the
		   try blocks */

		//Scanner kbd = new Scanner(System.in);
		//System.out.print("Enter Username: ");
		//username = kbd.nextLine(); //This is your username in oracle
		System.out.println();
		//System.out.print("Enter Password: ");
		//password = kbd.nextLine(); //This is your password in oracle
		//openDatabaseConnection();

	}
	
	private void openDatabaseConnection() 
	{
		try
		{
			// Register the oracle driver.  
			DriverManager.registerDriver (new oracle.jdbc.driver.OracleDriver());
			
			//This is the location of the database.  This is the database in oracle
			//provided to the class
			String url = "jdbc:oracle:thin:@db10.cs.pitt.edu:1521:dbclass"; 
			
			//create a connection to DB on db10.cs.pitt.edu
			connection = DriverManager.getConnection(url, username, password); 
			
			
			if(connection.isClosed() == false)
			{
				System.out.println("It appears we connected without any problems.");
				System.out.println("It appears the connection to the database was openened.");
			}
			else
			{
				System.out.println("It appears the connection to the database is closed.");
			}
			
			try 
			{
				connection.close();
			}
			catch(Exception Ex)  
			{
				System.out.println("Error connecting to database (main of CustomerInterface).  Machine Error: " +
						   Ex.toString());
			}
		}
		catch(Exception Ex)  {
			System.out.println("Error connecting to database.  Machine Error: " +
					   Ex.toString());
		}		
		
	}

	/* 1: Add customer */
	public void task1()
	{
		CustomerInfo customerAddress = new CustomerInfo();
		customerAddress.askCustomerForInfo();
	}
	
	
	public static void main(String [] args)
	{
		CustomerInterface demo = new CustomerInterface();	
		demo.task1();		
		//checkIfCustomerNameIsInDatabaseAlready();
	}
}


